package com.adolph.netty.nio;

import java.nio.IntBuffer;

/**
 * 〈功能概述〉<br>
 * NIO中的Buffer
 * @author: wangxiangjun
 * @date: 2020-10-01 8:41
 */

public class BasicBuffer {

    public static void main(String[] args) {
        IntBuffer allocate = IntBuffer.allocate(5);

        for (int i=0; i<allocate.capacity(); i++){
            allocate.put(10+i);
        }
        //从Buffer中取数据，将Buffer切换，读写切换
        allocate.flip();

        while (allocate.hasRemaining()){
            System.out.println(allocate.get());
        }
    }
}
